<?php
class Discount extends Zend_Db_Table {
	protected $_name = "cc_discount";
	private $db;
	
	/**
	 * 折扣构造函数
	 * @access public
	 * @return 
	 */
	public function __construct(){
		$this->db = Zend_Db_Table::getDefaultAdapter();
		parent::_setup();
	}
	/**
	 * 取所有折扣信息
	 * @access public
	 * @return array 所有折扣信息
	 */
	public function getAllDis(){
		$rowset = $this->fetchAll();
		$disArr = $rowset->toArray();
		return $disArr;
	}
	
	
	/**
	 * 添加点击数
	 * @param string $id
	 * @param int $clickcnt
	 */
	public function addClick($id, $clickcnt) {
		$data = array ('clickcnt' => $clickcnt );
		$updcnt = $this->update ( $data, 'id=' . $id );
		return $updcnt;
	}
	/**
	 * 
	 * @access public
	 * @return 
	 */
	public function getDiscountById($id){
		$where = $this->db->quoteInto("id=?",$id);
		$row = $this->fetchRow($where);
		return $discArr = $row->toArray();
	}
	/**
	 * 修改折扣信息
	 * @access public
	 * @return int 修改的条数
	 */
	public function updDiscount($data,$id){
		$where = $this->db->quoteInto("id=?",$id);
		$updcnt = $this->update($data,$where);
		return $updcnt;
	}
	/**
	 * 新增折扣信息
	 * @access public
	 * @return int 返回新增信息的ID
	 */
	public function insDiscount($data){
		$insid = $this->insert($data);
		return $insid;
	}

}
